<template>
  <div class="bordercontents-title2" :ref="ref">
    <svg class="dv-border-svg-container" :width="width" :height="defaultheight+1">
      <defs>
        <filter id="filterId" height="150%" width="150%" x="-25%" y="-25%">
          <feMorphology
            operator="dilate"
            radius="2"
            in="SourceAlpha"
            result="thicken"
          />
          <feGaussianBlur in="thicken" stdDeviation="3" result="blurred" />
          <feFlood flood-color="#2feefb" result="glowColor" />
          <feComposite
            in="glowColor"
            in2="blurred"
            operator="in"
            result="softGlowColored"
          />
          <feMerge>
            <feMergeNode in="softGlowColored" />
            <feMergeNode in="SourceGraphic" />
          </feMerge>
        </filter>
      </defs>
      <!-- 内容 -->
      <polyline
        :class="['', transfroms ? 'dot' : '']"
        :points="`2,2 10,2 ${width - 10},2 ${width - 2},2 ${width - 2},${
          defaultheight - 10
        } ${width - 2},2 ${width - 30},${defaultheight - 2} 30,${
          defaultheight - 2
        } 2 ,2 2,10`"
        style="fill: #25415c"
      />
      <!-- 下 -->
      <polyline
        :class="['dv-bb7-line-width-3']"
        stroke-dashoffset="1"
        :points="`${width - 18},30 ${width - 30},${defaultheight - 2} 30,${
          defaultheight - 2
        } 18 ,30 18,30`"
      >
        <!-- 使用动画 出现便宜的情况需要使用stroke-dashoffset配合stroke-dasharray进行调整 -->
        <animate
          v-if="transfroms"
          attributeName="stroke-dasharray"
          attributeType="XML"
          :from="`0, ${width / 2 - 15}, 0, ${width / 2}`"
          :to="`0, 0, ${width - 15},0`"
          :dur="`2s`"
          begin="0s"
          calcMode="spline"
          keyTimes="0;1"
          keySplines=".4,1,.49,.98"
          repeatCount="indefinite"
        />
      </polyline>
    </svg>
    <div class="echartCon">
      <div>
        <slot></slot>
      </div>
    </div>
  </div>
</template>
<script>
import autoMinix from "../autoResize";
import {defineComponent,toRaw} from "vue-demi";

export default defineComponent({
  name: "vtitleline2",
  mixins: [autoMinix],
  props: {
    transfroms: {
      type: Boolean,
      default: () => false,
    },
    filter: {
      type: Boolean,
      default: () => false,
    },
  },
    data(){
     return {
       ref:'vtitleline2',
     }
  },
  setup(){
    let ref = toRaw('vtitleline2');
    let defaultheight = 50;
    return {
      ref,
       defaultheight,
    };
  },
});
</script>

<style lang="less" scoped>
.dv-border-svg-container > polyline {
  fill: none;
  stroke-linecap: round;
}
.dv-bb7-line-width-2 {
  stroke-width: 2;
  stroke: #6fd1d8;
}
.dv-bb7-line-width-3 {
  stroke-width: 2;
  stroke: #2feefb;
}
.dv-bb7-line-width-4 {
  stroke-width: 3;
  stroke: #033c86;
}
.dv-bb7-line-width-5 {
  stroke-width: 1;
  stroke: #2feefb;
}
.bordercontents-title2 {
  position: relative;
  width: 100%;
  height: 100%;
}
.dv-border-svg-container {
  position: absolute;
  top: 0;
  left: 0;
}
.echartCon {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  text-align: center;
  & > div {
    border-radius: 15px;
  }
}
.echartCon > div {
  width: 100%;
  height: 100%;
}
.dot {
  stroke-dashoffset: 100;
  stroke-dasharray: 300;
  animation: dots 5s linear infinite;
}
@keyframes dots {
  0% {
    stroke-dashoffset: 300;
  }
  100% {
    stroke-dashoffset: 1500;
  }
}
</style>